package com.fuhao.pay.asyntask;

import com.fuhao.pay.entity.PaymentTransactionLogEntity;
import com.fuhao.pay.mapper.PaymentTransactionLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author zhang
 * @title: PayLogAsynTask
 */
@Component
@Slf4j
public class PayLogAsynTask {

    @Autowired
    private PaymentTransactionLogMapper paymentTransactionLogMapper;
    /**
     * 采用多线程技术或者MQ形式进行存放到数据库中
     *
     * @param paymentId
     * @param verifySignature
     */
    @Async
    public void payLog(String paymentId, Map<String, String> verifySignature) {
        log.info(">>>>>asyncCallBack service 02");
        log.info(">>paymentId:{paymentId},verifySignature:{}", verifySignature);
        PaymentTransactionLogEntity paymentTransactionLog = new PaymentTransactionLogEntity();
        paymentTransactionLog.setTransactionId(paymentId);
        paymentTransactionLog.setAsyncLog(verifySignature.toString());
        paymentTransactionLogMapper.insertTransactionLog(paymentTransactionLog);
        log.info(">>>>>asyncCallBack service 03");
    }
}
